//
//  GHSFundsViewController.m
//  penzer
//
//  Created by 还带大道 on 2018/11/14.
//  Copyright © 2018年 caiyc. All rights reserved.
//

#import "GHSFundsViewController.h"
#import "BZ_GHS_FoundView.h"
#import "BZ_GHS_TradDetailViewController.h"
#import "BZ_GHS_C_TradeDetailViewController.h"
#import "BZ_GHS_CacuCycleNote.h"
#import "BZ_GHS_AddAcountViewController.h"
#import "BZ_GHS_AddCompanyAcountViewController.h"
#import "BZ_GHS_SetPasswordViewController.h"
#import "BZ_GHS_SelectCardView.h"
#import "BZ_GHS_WithdrwwaRulrViewController.h"
@interface GHSFundsViewController ()<UIScrollViewDelegate>
@property (nonatomic,strong) BZ_GHS_CacuCycleNote *cycleNote;
@end

@implementation GHSFundsViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.navigationItem.title = @"资金明细";
    
    UITapGestureRecognizer *tap =[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hideKb)];
    [self.view addGestureRecognizer:tap];
    [self setUpRightItem];
    [self setUpScroView];
}


-(void)setUpRightItem
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(0, 0, 40, 40);
    [btn setImage:[UIImage imageNamed:@"帮助说明 (1)"] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(checkNote) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem =  [[UIBarButtonItem alloc] initWithCustomView:btn];;
}


-(void)checkNote
{
    if(![RZ_KEYWINDOW.subviews containsObject:self.cycleNote]){
        [RZ_KEYWINDOW addSubview:self.cycleNote];
    }
}


-(void)setUpScroView
{
    BZ_GHS_FoundView *shareView = [BZ_GHS_FoundView ShareHeadView];
    [self.ScroView addSubview:shareView];
    self.ScroView.delegate = self;
    __weak typeof(self)weakSelf = self;
    ///提现明细
    shareView.checkDraw=^(){
        BZ_GHS_TradDetailViewController *vc = [BZ_GHS_TradDetailViewController new];
        [self.navigationController pushViewController:vc animated:NO];
    };
    ///交易i明细
    shareView.checkDetail=^(){
        BZ_GHS_C_TradeDetailViewController *vc = [BZ_GHS_C_TradeDetailViewController new];
        [self.navigationController pushViewController:vc animated:NO];
    };
    ///确认提现
    shareView.confirm=^(){
        
    };
    ///查看原因
    shareView.checkReason=^(){
        BZ_GHS_WithdrwwaRulrViewController *vc = [BZ_GHS_WithdrwwaRulrViewController new];
        [self.navigationController pushViewController:vc animated:NO];
    };
    shareView.selectCard=^(){
        BZ_GHS_SelectCardView *view = [BZ_GHS_SelectCardView ShareCardView];
        view.backgroundColor =RGBA(0, 0, 0, .5);
        view.frame = CGRectMake(0, 0, screen_width, screen_height);
        view.addAcount=^(NSInteger type){
            if(type==0){
                BZ_GHS_AddCompanyAcountViewController *vc = [BZ_GHS_AddCompanyAcountViewController new];
                [self.navigationController pushViewController:vc animated:NO];
            }else{
                BZ_GHS_AddAcountViewController *vc =[BZ_GHS_AddAcountViewController new];
                [self.navigationController pushViewController:vc animated:NO];
            }
        };
        [[[UIApplication sharedApplication]keyWindow]addSubview:view];
      //  [view show];
    };
    [shareView mas_makeConstraints:^(MASConstraintMaker *make) {
        //在 左,上 添加约束 (左、上约束都是15）
        make.size.mas_equalTo(CGSizeMake(screen_width-30, 500));
        make.left.and.top. mas_equalTo(15);
    }];
    [self.ScroView addSubview:shareView];
    self.ScroView.showsVerticalScrollIndicator = 0;
    [self.ScroView setContentSize:CGSizeMake(0, screen_height*1.1)];
}


-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    [self.view endEditing:1];
}

-(void)hideKb{
    [self.view endEditing:1];
}


#pragma mark--getter&&setter
- (BZ_GHS_CacuCycleNote *)cycleNote
{
    if(!_cycleNote){
        _cycleNote = [BZ_GHS_CacuCycleNote ShareNoteView];
        _cycleNote.frame = RZ_KEYWINDOW.bounds;
    }
    return _cycleNote;
}

@end
